package dk.pekilidi.dod;

import dk.pekilidi.dod.Attribute.AttributeType;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * User: mpeki
 * Date: 12-12-2007
 * Time: 21:37:22
 */
public class Human extends BaseObject {

    public enum Handed {RIGHT, LEFT, DOUBLE, AMBI}

    private Map<AttributeType,Attribute> attributes;
    private Set<Skill> skills;
    private Set<Item> items;
    private Map<Limb.LimbType,Limb> limbs;
    private int maxTotalHP;
    private int currentTotalHP;
    private int originalTotalHP;
    private boolean hero;
    private String damageBonusDS;
    private Handed favoriteHand;
    private BeingConfiguration config;


    public Set<Item> getItems() {
        return items;
    }

    public void setItems(Set<Item> items) {
        this.items = items;
    }

    public Map<AttributeType,Attribute> getAttributes() {
        return attributes;
    }

    public Collection getAttributeMapValues() {
        return attributes != null ? attributes.values(): null;
    }

    public void setAttributes(Map<AttributeType,Attribute> attributes) {
        this.attributes = attributes;
    }

    public Attribute getAttribute(Attribute.AttributeType at){
        return attributes == null ? null : attributes.get(at);
    }

    public void setAttibute(Attribute a){
        if(attributes == null)
            attributes = new HashMap<AttributeType,Attribute>();

        attributes.put((AttributeType)a.getType(), a);
    }

    public Limb getLimb(Limb.LimbType lt){
        return limbs!=null ? limbs.get(lt) : null;
    }

    public void setLimb(Limb l){
        if(limbs == null)
            limbs = new HashMap<Limb.LimbType,Limb>();
        limbs.put((Limb.LimbType)l.getType(), l);
    }

    public Set<Skill> getSkills() {
        return skills;
    }

    public void setSkills(Set<Skill> skills) {
        this.skills = skills;
    }

    public Map<Limb.LimbType,Limb> getLimbs() {
        return limbs;
    }

    public void setLimbs(Map<Limb.LimbType,Limb> limbs) {
        this.limbs = limbs;
    }

    public int getMaxTotalHP() {
        return maxTotalHP;
    }

    /**
     * sets Max total hit point
     * @param maxTotalHP is a represents the current max hp value reachable when healing after injury
     */
    public void setMaxTotalHP(int maxTotalHP) {
        this.maxTotalHP = maxTotalHP;
    }

    public int getCurrentTotalHP() {
        return currentTotalHP;
    }

    public void setCurrentTotalHP(int currentTotalHP) {
        this.currentTotalHP = currentTotalHP;
    }

    public int getOriginalTotalHP() {
        return originalTotalHP;
    }

    public void setOriginalTotalHP(int originalTotalHP) {
        this.originalTotalHP = originalTotalHP;
    }

    public boolean isHero() {
        return hero;
    }

    public void setHero(boolean hero) {
        this.hero = hero;
    }

    public String getDamageBonusDS() {
        return damageBonusDS;
    }

    public Handed getFavoriteHand() {
        return favoriteHand;
    }

    public void setFavoriteHand(Handed favoriteHand) {
        this.favoriteHand = favoriteHand;
    }

    /**
     * A String describing a dice roll e.g. '1T6+2', the String must be formated like this 
     * @param damageBonusDS set dieString for damage bonus
     */
    public void setDamageBonusDS(String damageBonusDS) {
        this.damageBonusDS = damageBonusDS;
    }

    public BeingConfiguration getConfig() {
        return config;
    }

    public void setConfig(BeingConfiguration config) {
        this.config = config;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
                append("attributes", attributes).
                append("skills", skills).
                append("items", items).
                append("limbs", limbs).
                append("maxTotalHP", maxTotalHP).
                append("currentTotalHP", currentTotalHP).
                append("originalTotalHP", originalTotalHP).
                append("hero", hero).
                append("damageBonusDS", damageBonusDS).
                append("favoriteHand", favoriteHand).
                append("config", config).
                toString();
    }
}
